<?php
namespace Modules\Auth\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Modules\Auth\Models\User;

class RegisterController extends Controller{
    public function store(Request $request){
            $validated = $request->validate([
                'name' => 'required|max:255',
                'email' => 'required|email|unique:users,email|max:255',
                'password' => 'required|min:6'
            ]);
            // 加密密码
            $validated['password'] = bcrypt($validated['password']);
            // 创建用户
            $user = User::create($validated);
            return response()->json(['status' => 'success', 'data' => $user], 201);
    }
}
